function likes(names) {
    var templates = [
        'no one likes this',
        '{name} likes this', //{...}是占位符
        '{name} and {name} like this',
        '{name}, {name} and {name} like this',
        '{name}, {name} and {n} others like this'
    ];
    var idx = Math.min(names.length, 4);
    /{name}/
    return templates[idx].replace(/{name}|{n}/g, function (val) {
        return val === "{name}" ? names.shift() : names.length;
    })
}





console.log(likes([]));
console.log(likes(["Peter"]));
console.log(likes(["Jacob", "Alex"]));
console.log(likes(["Max", "Jhon", "Mark"]));
console.log(likes(["Alex", "Jacob", "Mark", "Max"]));